﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuanLyHocPhi.Model;

namespace QuanLyHocPhi.BLL
{
    partial class BizLoaiHinhDaoTao
    {
        /// <summary>
        /// Lấy danh sách loại hình đào tạo
        /// </summary>
        /// <returns></returns>
        internal static List<LoaiHinhDaoTao> GetListLoaiHinh()
        {
            using (var context = new QLHPEntities())
            {
                var lt = from lh in context.LoaiHinhDaoTaoDbSet
                         select lh;
                return lt.ToList();
            }
        }

        internal static IList<string> GetList_NamTuyenSinh(string maLoaiHinh)
        {
            using (var context = new QLHPEntities())
            {
                var lstGroupNamTS = from lop in context.LopGocDbSet
                                    where lop.MaLoaiHinhDaoTao == maLoaiHinh
                                    group lop by lop.NamTuyenSinh into NamTSGroup
                                    orderby NamTSGroup.Key descending
                                    select new { NamTS = NamTSGroup.Key };
                var lstNamTS = new List<string>();
                foreach (var group in lstGroupNamTS)
                    lstNamTS.Add(group.NamTS.ToString());
                return lstNamTS;
            }
        }
    }
}
